/*--------------------------------------------------------------------------
  Project::MONDIALI SCI ALPINISMO
  Package::States
  Class::ViewBriefingState
  File ViewBriefingState.h
  --------------------------------------------------------------------------
  * METHODS AND CLASS PARAMETERS


  --------------------------------------------------------------------------
  * FUNCTIONS DESCRIPTION
  
	...

  --------------------------------------------------------------------------
  * COPYRIGHT

  --------------------------------------------------------------------------
  * INFO ABOUT AUTHOR AND VERSIONS
  Author:	Tino Giorgio	Data: 
  Rev1:			Data:

  --------------------------------------------------------------------------
  * E-MAIL & CONTACTS

  GIORGIO TINO:	tinoshi@libero.it
	           	shapeofangels@hotmail.com
	            giorgio.tino@studenti.polito.it

  --------------------------------------------------------------------------*/

#if !defined(VIEWBRIEFINGSTATE_H)
#define VIEWBRIEFINGSTATE_H

#include <stdio.h>

#include <plib/ul.h>
#include <plib/ssg.h>
#include <plib/js.h>
#include <plib/pu.h>

/* Application Includes*/
#include "State.h"
#include "LoadingInfo.h"

#ifndef NUM_MAP_WIDGETS 
#define NUM_MAP_WIDGETS 4
#endif
#ifndef CAMERA_PROGRESS
#define CAMERA_PROGRESS 0.2f
#endif

#define FREE_VIEW  0
#define MOVIE_VIEW 1

#define NUM_PLAYER_BUTTONS    4
#define PLAYER_BUTTON_WIDTH  20
#define PLAYER_BUTTON_HEIGTH 20
#define PLAYER_START_Y       25

#define INFO_GO_TO_FREE_VIEW            "      Press 'e' to switch to free move view     \0"
#define INFO_GO_TO_MOVIE_VIEW           "        Press 's' to return to movie view       \0"

#define BRV_TEXT_LENGTH 1024

/* DEFINES */
class LoadBriefingState;
class Scenegraph;
class Camera;
class Mouse;
class Keyboard;
class Joystick;
class Land;
class MapImage;
class FPSTest;

class ViewBriefingState : public State
{
public:
	ViewBriefingState(State* os,LoadingInfo* li);
	virtual ~ViewBriefingState();
	
	//
	// Static callbacks (for PUI menu)
	//
	static void playm_cb ( puObject * );
	static void stopm_cb ( puObject * );
	
	// class 'callbacks' (they aren't callbacks really...)
	void load(const char* filename);
    void display(void);
    void resize(int w, int h);
    void keyUp(unsigned char key, int x, int y);
    void keyDown(unsigned char key, int x, int y);
    void specialUp(int key, int x, int y);
    void specialDown(int key, int x, int y);
    void motion(int newx, int newy); 
    void passive(int newx, int newy);
    void mouse(int button, int state, int mouseX, int mouseY);
    State* idle(void);
	void reset();
	void goBack();
	
	void saveScenario();
	void loadScenario();

	void loadCameraPosition(FILE* f);

	void start();
	void end();
	void play();
	void stop();
	void forward();
	void rewind();

	void bindTextures();
	void createStates();
    
private:
    ulClock *ck;
	Scenegraph *scene;
	Camera *camera;

	Mouse *ms;
	Keyboard *kb;
	Joystick *js;

	State *oldState,*nextState;

	Land *l;
	
	LoadingInfo *info;

	MapImage* mapsWidget[NUM_MAP_WIDGETS];
	int current_map_widget;

	int v;
	float x,y,z,h,p,r;

	// Test
	FPSTest		*fps;
	puText		*fps_text;
	char		fps_text_legend[1024];

	// file names
	char snr_filename[1024];
	char dem_filename[1024];
	char obj_filename[1024];
	char tex_filename[1024];
	char map_filename[1024];

	void readBriefingFile(LoadingInfo* li);

	int inner_state;

	puGroup     *infoGroup,*player;

	puArrowButton *playButton;
	puArrowButton *stopButton;
	puArrowButton *forwardButton;
	puArrowButton *rewindButton;

	puText		*info_text;
	char		info_text_legend[BRV_TEXT_LENGTH];
};

#endif // !defined(VIEWBRIEFINGSTATE_H_)
